//
//  HWWelfareCenterHeader.swift
//  HWanGame
//
//  Created by 王昌健 on 2022/4/2.
//  Copyright © 2022 94Wan. All rights reserved.
//

import UIKit

class HWWelfareCenterHeader: UITableViewHeaderFooterView {
    var leftView:UIView!
    var titleLabel:UILabel!
    
    class func headerOrFooterWithTableView(tableView:UITableView) -> (HWWelfareCenterHeader) {
        let reUse:String = "HWWelfareCenterHeader"
        
        var headerOrFooter = tableView.dequeueReusableHeaderFooterView(withIdentifier: reUse)
        
        if headerOrFooter == nil {
            headerOrFooter = HWWelfareCenterHeader.init(reuseIdentifier: reUse)
        }
        
        return headerOrFooter as! HWWelfareCenterHeader
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override init(reuseIdentifier: String?) {
        super.init(reuseIdentifier: reuseIdentifier)
        initUI()
        initFrame()
    }
    
    
    func initUI() -> Void {
        
        backgroundView = UIView()
        contentView.backgroundColor = .white
        
        titleLabel = HWLabel.createBoldLabel(title: "平台活动", color: "#444444", font: 20*widthScale)
        contentView.addSubview(titleLabel)
        
        leftView = UIView()
        leftView.backgroundColor = .colorWithHexString(hexString: "#F87706")
        contentView.addSubview(leftView)
        
        
    }
    
    func initFrame() -> Void {
        leftView.snp.makeConstraints { make in
            make.width.equalTo(5*widthScale)
            make.height.equalTo(18*widthScale)
            make.left.equalTo(20*widthScale)
            make.top.equalTo(25*widthScale)
        }
        titleLabel.snp.makeConstraints { make in
            make.left.equalTo(leftView.snp.right).offset(6*widthScale)
            make.centerY.equalTo(leftView)
        }
    }
}
